package com.excellent.controller;

import com.excellent.entity.User;
import com.excellent.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/examples")
public class UserController {
    @Autowired
    UserService userService;
    @GetMapping
    public List<User> getAll() {
        List<User> all = userService.findAll();
        System.out.println(all);
        return all;
    }
    @PostMapping
    public void create(@RequestBody User entity) {
        userService.insert(entity);
    }

    @PutMapping
    public void update(@RequestBody User entity) {
        userService.update(entity);
    }

    @DeleteMapping("/{id}")
    public void delete(@PathVariable Long id) {
        userService.delete(id);
    }
}